package com.example.userserver.dao;

import com.example.server_engineer.dao.AbstractDao;
import com.example.userserver.entities.User;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.Optional;


/**
 * @author Administrator
 */
public interface UserDao extends
        AbstractDao<User,Long> {

    Optional<User> findByIdAndPassword(Long userid,String password);

    @Modifying
    @Transactional
    @Query(value = "update user set img=? where id=?",nativeQuery = true)
    Integer updateImgByUserId(String img,String id);

    User findByUsernameAndPassword(String username, String password);

    User findUserByUsername(String username);

    User findUserByEmail(String email);

    User findUserByTelOrMobilePhone(String tel, String mobbile);
}
